#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
# https://bitbucket.org/anthony_tuininga/cx_freeze/issues/161/cant-freeze-tcl-tk-code-on-os-x-1011
import numpy as np

if getattr(sys, 'frozen', False):
    application_path = os.path.dirname(sys.executable)
elif __file__:
    application_path = os.path.dirname(__file__)

# config_path = os.path.join(application_path, config_name)
sys.path.append(os.path.join(application_path,'lib'))
print sys.path
print sys.argv[0]
print sys.executable
print os.path.abspath(sys.argv[0])
ddir = sys.path[0]
if os.path.isfile(ddir):
    ddir, filen = os.path.split(ddir)
# print os.chdir(ddir)
import cv2
cap = cv2.VideoCapture(0)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 320)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 240)

while (True):
    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame', gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
